package com.rhaggarty.data.type.game;

/**
 * A representation of the available suits.
 * 
 * @author Ryan Haggarty (ryanmh at gmail dot com)
 * 
 */
public enum Suit {

    SPADES('s'), HEARTS('h'), DIAMONDS('d'), CLUBS('c');

    private final char code;

    private Suit(final char code) {
        this.code = code;
    }

    public static Suit fromCode(final char code) {
        for (final Suit suit : values()) {
            if (suit.code == code) {
                return suit;
            }
        }

        throw new IllegalArgumentException("Suit not found for code: " + code);
    }

    public char getCode() {
        return code;
    }
}